/**
 * 
 */
package com.freecsim.sas.util;

import java.awt.Font;
import java.awt.Shape;
import java.awt.font.FontRenderContext;
import java.awt.font.GlyphVector;
import java.awt.geom.AffineTransform;
import java.io.PrintStream;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author Georgewu
 *
 */
public class GplyphPrinter {
	
	private static Logger logger = LoggerFactory.getLogger(GplyphPrinter.class);
	
	private static String default_char = "*";
	
	private static Font font = new Font("simsun", Font.BOLD, 15); 

	public static void printCharGraphy(String msg){
		if(StringUtils.isEmpty(msg)){
			return;
		}
		try 
		{ 
			AffineTransform at = new AffineTransform(); 
			FontRenderContext frc = new FontRenderContext(at, true, true); 
			GlyphVector gv = font.createGlyphVector(frc, msg);  
			Shape shape = gv.getOutline(10, 10); 
			int weith = 100; 
			int height = 10; 
			boolean[][] view = new boolean[weith][height]; 
			for (int i = 0; i < weith; i++) 
			{ 
				for (int j = 0; j < height; j++) 
				{ 
					if (shape.contains(i, j)) 
					{ 
						view[i][j] = true; 
					} else 
					{ 
						view[i][j] = false; 
					} 
				} 
			} 
			for (int j = 0; j < height; j++) 
			{ 
				for (int i = 0; i < weith; i++) 
				{ 
					if (view[i][j]) 
					{ 
						System.out.print(default_char);
					} else 
					{ 
						System.out.print(" "); 
					} 
				} 
				System.out.println(); 
			} 
		} catch (Exception e) 
		{ 
			e.printStackTrace(); 
		} 
	}
}
